    <?php 
    $groups=$viewModel->get('groups'); 
    $quantityUsers=$viewModel->get('quantityUsers');
    $countGroup=$viewModel->get('countGroup');
    $pageCurrent=$viewModel->get('pageCurrent');
    $pageNumber=ceil($countGroup/ROWOFPAGE);
    
    $i=0;
    include 'views/Include/alert.php';
    ?>
    <div class="container-fluid" style="width:97%">
            <h2>QUẢN LÝ NHÓM QUYỀN</h2>
            <hr>
            <form class="form-inline" action="<?php echo BASE_URL.'group/getFunction';?>" onsubmit="return ConfirmChoiceDeleteMulti();" method="POST">
                <a href="<?php echo BASE_URL.'group/create';?>" class=""><span class="glyphicon glyphicon-plus"></span> Thêm nhóm quyền</a>
                <div class="pull-right">
                    <input type="text" class="form-control" id="inputsearch" name="txtsearch" placeholder="Nhập từ tìm kiếm">
                    <input type="submit" class="btn btn-default" id="search-submit" name="btnsearch" value="Tìm kiếm nhóm quyền">
                </div>
                <div class="tablenav top">
                    <select class="form-control input-sm" name="action">
                        <option selected="selected" value="">Tác vụ</option>
                        <option value="delete">Xóa </option>
                    </select>
                    <input type="submit" class="btn btn-default btn-sm" id name="delete-multi" value="Áp dụng">
                    <div class="tablenav-pages">
                        <span class="displaying-num"><?php echo $countGroup;?> chỉ mục</span>
                           <!--<span class="pagination-links"><a class="first-page disabled" title="Quay lại trang đầu tiên" href="">«</a>
                                <a class="prev-page disabled" title="Quay lại trang trước" href="#">‹</a>
                                <span class="paging-input"><input class="current-page" title="Trang hiện tại" type="text" name="paged" value="1" size="1"> trên <span class="total-pages">1</span></span>
                                <a class="next-page disabled" title="Tới trang sau" href="#">›</a>
                                <a class="last-page disabled" title="Tới trang cuối" href="#">»</a></span>
                            </div>-->
                    </div>
                </div>
                <table class="table table-striped">
                    <thead>
                        <th width="3%"><input type="checkbox"></th>
                        <th class="cursor">ID</th>
                        <th class="cursor">Tên quyền</th>
                        <th>Mô tả</th>
                        <th>Số người trong nhóm</th>
                    </thead>
                    <tbody>
                    <?php
                        if (is_null($groups)){
                            echo "Chưa có thành viên nào";
                        }
                        else {
                            foreach ($groups as $group) {
                                
                    ?>
                        <tr class="click">
                            <td><input type="checkbox" name="check_list[]" value="<?php echo $group->Id; ?>"></td>
                            <td><?php echo $group->Id; ?><br>
                                <div class="row-action">
                                    <span class="edit"><a href="<?php echo BASE_URL.'group/update/'.$group->Id;?>">Chỉnh sửa</a> |</span> 
                                    <span class="delete"><a href="" onclick="ConfirmChoiceDelete('<?php echo BASE_URL.'group/delete/'.$group->Id;?>'); return false;">Xóa</a></span> 
                                </div>
                            </td>
                            <td><?php echo $group->TenNhom; ?></td>
                            <td><?php echo $group->MoTa; ?></td>
                            <td><?php foreach ($quantityUsers as $quantityUser) {
                                if($quantityUser->Id==$group->Id) {
                                    echo $quantityUser->SoNguoi;
                                    break;
                                }
                            }?></td>
                        </tr>
                        <?php } }?>
                    </tbody>
                    <tfoot>
                        <th width="3%"><input type="checkbox"></th>
                        <th class="cursor">ID</th>
                        <th class="cursor">Tên quyền</th>
                        <th>Mô tả</th>
                        <th>Số người trong nhóm</th>
                    </tfoot>
                </table>
                <div class="tablenav bottom" name="">
                    <select class="form-control input-sm">
                        <option selected="selected" value="">Tác vụ</option>
                        <option value="">Xóa </option>
                    </select>
                    <input type="submit" class="btn btn-default btn-sm" id name="btnapply" value="Áp dụng">
                    <div class="tablenav-pages">
                        <span class="displaying-num"><?php echo $countGroup;?> chỉ mục</span>
                           <!--<span class="pagination-links"><a class="first-page disabled" title="Quay lại trang đầu tiên" href="">«</a>
                                <a class="prev-page disabled" title="Quay lại trang trước" href="#">‹</a>
                                <span class="paging-input"><input class="current-page" title="Trang hiện tại" type="text" name="paged" value="1" size="1"> trên <span class="total-pages">1</span></span>
                                <a class="next-page disabled" title="Tới trang sau" href="#">›</a>
                                <a class="last-page disabled" title="Tới trang cuối" href="#">»</a></span>
                            </div>-->
                    </div>
                </div>
            </form>
            <!-- phân trang -->
        <div class="row">
            <div class="col-md-10">
              <?php 
                    if($pageCurrent>1){echo '<a class="btn btn-success" href="'.BASE_URL.'group/'.($pageCurrent-1).'">Trang trước</a>';}
                    echo '&nbsp;';
              for ($i=1 ; $i<=$pageNumber ; $i++) {
                if ($i == $pageCurrent) {
                       echo $i;
                       echo '&nbsp;';
                } 
                else {
                      echo '<a class="btn btn-info" href="'.BASE_URL.'group/'.$i.'">'.$i.'</a>';
                      echo '&nbsp;';
                }
              }
              if($pageCurrent<$pageNumber){echo '<a class="btn btn-success" href="'.BASE_URL.'group/'.($pageCurrent+1).'"">Trang sau</a>';}
            ?>
            </div>
        </div>
    </div>

    <script type="text/javascript">$('.list > li a').click(function() {
    $(this).parent().find('ul').toggle();
});</script> 
